const mysql = require('mysql')
 
const connection = mysql.createConnection({
    host: 'localhost',
    port: 3308,
    user: 'root',
    password: '123456789',
    database: 'message'
    
})

connection.connect();


function query(sql, data) {
    return new Promise((resolve, reject) => {
        connection.query(sql, data, (error, result) => {
            if (error) {
                reject(error)
            } else {
                resolve(result)
            }
        })
        connection.end()
    })
}




connection.end();